package com.jzo2o.customer.controller.operation;

import cn.hutool.core.bean.BeanUtil;
import com.jzo2o.common.model.CurrentUserInfo;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.customer.model.domain.AgencyCertificationAudit;
import com.jzo2o.customer.model.dto.request.AgencyCertificationAuditPageQueryReqDTO;
import com.jzo2o.customer.model.dto.response.AgencyCertificationAuditResDTO;
import com.jzo2o.customer.model.dto.response.AgencyCertificationResDTO;
import com.jzo2o.customer.service.IAgencyCertificationService;
import com.jzo2o.mvc.utils.UserContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description aaa
 * @Author loe
 * @Date 2024-08-14
 */
@RestController("operationAgencyCertificationAuditController")
@RequestMapping("/operation/agency-certification-audit")
@Api(tags = "运营端 - 机构认证信息审核相关接口")
public class AgencyCertificationAuditController {

    @Resource
    private IAgencyCertificationService agencyCertificationService;

    @GetMapping("/page")
    public PageResult<AgencyCertificationAuditResDTO> page(AgencyCertificationAuditPageQueryReqDTO pageQueryReqDTO) {
        CurrentUserInfo currentUserInfo = UserContext.currentUser();
        Long auditorId = currentUserInfo.getId();
        String auditorName = currentUserInfo.getName();
        return agencyCertificationService.getPage(pageQueryReqDTO, auditorId, auditorName);
    }

    @PutMapping("audit/{id}")
    @ApiOperation("审核服务人员认证信息")
    public void audit(
            @PathVariable(value = "id", required = true) Long id,
            @RequestParam(value = "certificationStatus", required = true) Integer certificationStatus,
            @RequestParam(value = "rejectReason", required = false) String rejectReason) {
        CurrentUserInfo currentUserInfo = UserContext.currentUser();
        Long auditorId = currentUserInfo.getId();
        String auditorName = currentUserInfo.getName();
        agencyCertificationService.audit(id, certificationStatus, rejectReason, auditorId, auditorName);
    }

}
